//提出问题的请求
export function pushQuestionRequest(context,question){
    const questionObject={"isFromUser": true, "content": question.question,}
    context.commit('pushQuestion',questionObject)
    chatRequest(context,question.question)
}
function chatRequest(context,question){
    const source = new EventSource(`http://49.232.29.89:8000/stream?question=${question}`);
    context.commit('pushQuestion',{"isFromUser": false, "content":''})
    source.onmessage = (event) => {
        const data = event.data;
        if (data!== null) {
            context.commit('addAnswerContext',data)
        }
    };

    source.onerror = () => {
        // 处理连接错误或传输结束的情况
        source.close();
    };
}
